package il.ac.tau.cvws.scrabblesidekick.client.util.dictionary.hebrew;

import il.ac.tau.cvws.scrabblesidekick.client.app.AppServices;
import android.text.InputFilter;
import android.text.Spanned;

/* This filter is intended to not allow the user to input non-Hebrew characters
 * when asked to enter their rack letters.
 */
public class HebrewFilter implements InputFilter
{
	@Override
	public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend)
	{
		for (int i = start; i < end; i++) 
		{ 
            if (!AppServices.instance().dictionary().exists(source.charAt(i))) 
            { 
            	return source.subSequence(start, start); 
            }
        }

		return null;
	}
}
